home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Draw / Include / DrawSel.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  9.0 KB  |  268 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawSel.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWSEL_H
  13. #define DRAWSEL_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWSLCING_H
  18. #include "FWSlcing.h"
  19. #endif
  20.  
  21. // ----- OS Layer -----
  22.  
  23. #ifndef FWRECT_H
  24. #include "FWRect.h"
  25. #endif
  26.  
  27. #ifndef FWRECSHP_H
  28. #include "FWRecShp.h"
  29. #endif
  30.  
  31.  
  32. //========================================================================================
  33. //    Forward Declarations
  34. //========================================================================================
  35.  
  36. #if FW_LIB_EXPORT_PRAGMAS
  37. #pragma import on
  38. #endif
  39. class FW_CLASS_ATTR FW_CGraphicContext;
  40. class FW_CLASS_ATTR FW_CMouseEvent;
  41. class FW_CLASS_ATTR FW_PPattern;
  42. class FW_CLASS_ATTR FW_CColor;
  43. class FW_CLASS_ATTR FW_CPrivOrderedCollection;
  44. #if FW_LIB_EXPORT_PRAGMAS
  45. #pragma import off
  46. #endif
  47.  
  48. class FW_CLASS_ATTR CDrawPart;
  49. class FW_CLASS_ATTR CDrawFrame;
  50. class FW_CLASS_ATTR CSelectionIterator;
  51. class FW_CLASS_ATTR CDrawSelection;
  52. class FW_CLASS_ATTR CBaseShape;
  53.  
  54. //========================================================================================
  55. //    class CDrawSelection
  56. //========================================================================================
  57.  
  58. class FW_CLASS_ATTR CDrawSelection : public FW_CEmbeddingSelection
  59. {
  60. //----------------------------------------------------------------------------------------
  61. //    Initialization/Destruction
  62. //
  63. public:
  64.     CDrawSelection(Environment* ev, CDrawPart* drawPart);
  65.     virtual         ~CDrawSelection();
  66.     
  67. //----------------------------------------------------------------------------------------
  68. //    Inherited API
  69. //
  70. public:
  71.     virtual void        CloseSelection(Environment* ev);
  72.     virtual void        SelectAll(Environment* ev);
  73.     virtual FW_Boolean    IsEmpty(Environment* ev) const;
  74.     virtual FW_Boolean    ClearSelection(Environment* ev);
  75.     virtual FW_MProxy*    IsSelectionOnlyOneProxy(Environment* ev) const;
  76.     
  77.     virtual ODShape*    CreateSelectionFrameShape(Environment* ev) const;
  78.     
  79.     virtual ODShape*    CreateSelectionShape(Environment* ev, ODFacet* facet, FW_CFrame* frame) const;
  80.     virtual ODShape*    CreateSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame) const;
  81.     
  82.     virtual void        DoExternalizeSelection(Environment* ev, 
  83.                                 ODStorageUnit* destinationSU, 
  84.                                 FW_CCloneInfo* cloneInfo);
  85.     virtual FW_Boolean    DoInternalizeSelection(Environment* ev, 
  86.                                 ODStorageUnit* storageUnit, 
  87.                                 FW_CCloneInfo* cloneInfo);
  88.                                 
  89.     virtual FW_Boolean    CanSubscribe(Environment* ev, ODPasteAsMergeSetting& setting);
  90.     virtual FW_Boolean    IsSelectionPublishable(Environment* ev);
  91.     
  92.     virtual FW_Boolean    InsertNewPart(Environment* ev, FW_CFrame* scopeFrame);
  93.  
  94.     virtual FW_CPromise*    NewPromise(Environment* ev, 
  95.                                         ODUpdateID updateID, 
  96.                                         FW_EStorageKinds storageKind, 
  97.                                         FW_CFrame* scopeFrame, 
  98.                                         ODCloneKind cloneKind);
  99.  
  100.     virtual FW_Boolean    IsMouseInDraggableItem(Environment* ev, 
  101.                             FW_CFrame* frame,
  102.                             const FW_CMouseEvent& theMouseEvent, 
  103.                             FW_Boolean inBackground);
  104.  
  105.     virtual void        UpdateSelectionOnMouseDown(Environment* ev, 
  106.                             const FW_CMouseEvent& mouseEvent,
  107.                             ODFacet* embeddedFacet,
  108.                             FW_Boolean inEmbeddedFrameBorder,
  109.                             FW_Boolean inBackground);
  110.     
  111. //----------------------------------------------------------------------------------------
  112. //    New API
  113. //
  114. public:
  115.     CBaseShape*     WhichHandle(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& mouse, short& whichHandle) const;
  116.     
  117.     void            RenderSelectionHandles(Environment* ev, FW_CGraphicContext& gc);
  118.     void            RenderHandles(Environment* ev, CBaseShape* shape);
  119.     void            RenderAllHandles(Environment* ev, FW_CFrame* frame);
  120.     
  121.     void            AddToSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  122.     void            RemoveFromSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  123.  
  124.     void            MapSelection(Environment* ev, const FW_CRect& srcRect, const FW_CRect& dstRect);
  125.     void            OffsetSelection(Environment* ev, FW_CFixed xDelta, FW_CFixed yDelta);
  126.  
  127.     FW_Boolean        Resize(Environment* ev, const FW_CMouseEvent& theMouseEvent);    
  128.  
  129.     void            SelectWithRectangle(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  130.  
  131.     FW_Boolean        GetSelectionPenSize(Environment* ev, FW_CFixed& penSize);
  132.  
  133.     void            ChangeSelectionPenSize(Environment* ev, FW_CFixed newPenSize);
  134.     void            ChangeSelectionRenderVerb(Environment* ev, unsigned short newRenderVerb);
  135.     
  136.     void            ChangeSelectionColor(Environment* ev, const FW_CColor& color, FW_Boolean changeFill);
  137.     void            ChangeSelectionPattern(Environment* ev, const FW_PPattern& pattern, FW_Boolean changeFill);
  138.  
  139.     FW_CPoint        AdjustSelectionAfterPaste(Environment* ev, FW_CFrame* scopeFrame);
  140.  
  141.     FW_Boolean        HasProxySelected() const;
  142.     
  143.     unsigned long    Count() const;
  144.     
  145.     // ----- Frozen state -----
  146.     FW_Boolean        HasFrozen() const;
  147.     FW_Boolean        HasNotFrozen() const;
  148.     void            SetFrozen(Environment* ev, FW_Boolean state);
  149.     
  150.     ODShape*        GetUpdateShape() const;
  151.     void            GetDragRect(FW_CRect& dragRect) const;
  152.  
  153.     void            RedrawShape(Environment* ev, CBaseShape *shape);
  154.     
  155.     // ----- Anchor Shape -----
  156.     CBaseShape*        GetAnchorShape() const;
  157.     void            SetAnchorShape(CBaseShape* shape);
  158.  
  159.  
  160.     // ----- Linking -----
  161.     void            SelectionChanged(Environment* ev);
  162.     void            DeleteSelection(Environment* ev);
  163.     FW_Boolean        IsOKtoEdit(Environment* ev);
  164.  
  165.     // ----- Selection Collection -----
  166.      FW_CPrivOrderedCollection*    GetSelectionCollection() const;
  167.  
  168. private:
  169.     void            CalcCache(Environment* ev);
  170.     
  171.     void            DoAdd(Environment* ev, CBaseShape *shape);
  172.     void            DoRemove(Environment* ev, CBaseShape *shape);
  173.         
  174. //----------------------------------------------------------------------------------------
  175. //    Data Members
  176. //
  177. private:
  178.     CDrawPart*            fDrawPart;
  179.     FW_CRect            fDragRect;
  180.     ODShape*            fUpdateShape;
  181.     unsigned short        fProxyShapeCount;
  182.     unsigned short        fFrozenCount;
  183.     unsigned long        fCount;
  184.     CBaseShape*            fAnchorShape;
  185.     short                fClickedHandle;
  186.     
  187.     FW_CPrivOrderedCollection*    fCollection;
  188.     
  189.     FW_CRectShape        fWorkingHandle;
  190. };
  191.  
  192. //========================================================================================
  193. //    CDrawSelection Inlines
  194. //========================================================================================
  195.  
  196. //----------------------------------------------------------------------------------------
  197. //    CDrawSelection::HasProxySelected
  198. //----------------------------------------------------------------------------------------
  199. inline FW_Boolean CDrawSelection::HasProxySelected() const
  200. {        
  201.     return fProxyShapeCount != 0;
  202. }
  203.  
  204. //----------------------------------------------------------------------------------------
  205. //    CDrawSelection::GetUpdateShape
  206. //----------------------------------------------------------------------------------------
  207. inline ODShape* CDrawSelection::GetUpdateShape() const
  208. {        
  209.     return fUpdateShape;
  210. }
  211.  
  212. //----------------------------------------------------------------------------------------
  213. //    CDrawSelection::GetDragRect
  214. //----------------------------------------------------------------------------------------
  215. inline void CDrawSelection::GetDragRect(FW_CRect& dragRect) const
  216. {        
  217.     dragRect = fDragRect;
  218. }
  219.  
  220. //----------------------------------------------------------------------------------------
  221. //    CDrawSelection::HasFrozen
  222. //----------------------------------------------------------------------------------------
  223. inline FW_Boolean CDrawSelection::HasFrozen() const
  224. {
  225.     return fFrozenCount != 0;
  226. }
  227.  
  228. //----------------------------------------------------------------------------------------
  229. //    CDrawSelection::HasNotFrozen
  230. //----------------------------------------------------------------------------------------
  231. inline FW_Boolean CDrawSelection::HasNotFrozen() const
  232. {
  233.     return fCount != 0 && fFrozenCount != fCount;
  234. }
  235.  
  236. //----------------------------------------------------------------------------------------
  237. //    CDrawSelection::Count
  238. //----------------------------------------------------------------------------------------
  239. inline unsigned long CDrawSelection::Count() const
  240. {
  241.     return fCount;
  242. }
  243.  
  244. //----------------------------------------------------------------------------------------
  245. //    CDrawSelection::GetAnchorShape
  246. //----------------------------------------------------------------------------------------
  247. inline CBaseShape* CDrawSelection::GetAnchorShape() const
  248. {
  249.     return fAnchorShape;
  250. }
  251.  
  252. //----------------------------------------------------------------------------------------
  253. //    CDrawSelection::SetAnchorShape
  254. //----------------------------------------------------------------------------------------
  255. inline void CDrawSelection::SetAnchorShape(CBaseShape* shape)
  256. {
  257.     fAnchorShape = shape;
  258. }
  259.  
  260. //----------------------------------------------------------------------------------------
  261. //    CDrawSelection::GetSelectionCollection
  262. //----------------------------------------------------------------------------------------
  263. inline FW_CPrivOrderedCollection*    CDrawSelection::GetSelectionCollection() const
  264. {
  265.     return fCollection;
  266. }
  267.  
  268. #endif